<!-- #layout name=blank-->
<div id="app" v-cloak>
  <div class="page-header">
    <h1 class="title">{{ Kooboo.text.common.Contents + ": " + folderName }}</h1>

    <div>
      <div class="input-group input-large pull-right">
        <input
          type="text"
          v-model="searchKey"
          @keyup.enter="searchStart"
          class="form-control"
          style="height: 32px"
          placeholder="输入关键字"
        />
        <div class="input-group-btn">
          <button class="btn btn-default" @click="searchStart"
            ><i class="fa fa-search"></i>Search</button
          >
        </div>
      </div>
    </div>
  </div>
  <kb-breadcrumb :breads="breads"></kb-breadcrumb>
  <div class="navbar navbar-default">
    <div class="container-fluid">
      <a
        class="btn btn-link disabled navbar-btn"
        v-if="isSearching"
        href="javascript:;"
        >Search result</a
      >
      <a :href="newTextContent" v-else class="btn green navbar-btn"
        >{{ Kooboo.text.site.textContent.new + " " + folderName }}</a
      >
      <a
        v-if="selected.length == 1"
        @click="onCopy"
        class="btn green navbar-btn"
        >Copy</a
      >
      <a v-if="selected.length > 0" @click="onDelete" class="btn red navbar-btn"
        >Delete</a
      >
      <a
        @click="onEditContentType"
        v-if="!isSearching"
        v-kb-tooltip:left="Kooboo.text.site.contentType.editContentType"
        href="javascript:;"
        class="btn btn-default navbar-btn pull-right"
        ><i class="fa fa-gear"></i
      ></a>
      <a
        v-else
        href="javascript:;"
        class="btn btn-default navbar-btn pull-right"
        @click="clearSearching"
        ><i class="fa fa-close"></i
      ></a>
    </div>
  </div>

  <kb-table
    :data="tableData"
    show-select
    :selected.sync="selected"
    v-if="showTable"
  >
    <kb-table-column :label="defaultColumnName">
      <template v-slot="row">
        <a :href="row[defaultColumnName].url" @click.stop
          >{{ row[defaultColumnName].text }}</a
        >
      </template>
    </kb-table-column>

    <kb-table-column v-for="item in listKeys" :prop="item" :label="item">
    </kb-table-column>

    <kb-table-column :label="Kooboo.text.common.online">
      <template v-slot="row">
        <span :class="['label', row.online.class]">{{ row.online.text }}</span>
      </template>
    </kb-table-column>
    <kb-table-column
      :label="Kooboo.text.common.lastModified"
      prop="lastModified"
    ></kb-table-column>
    <kb-table-column head-class="table-action" body-class="table-action">
      <template v-slot="row">
        <a class="btn btn-sm blue" :href="row.Edit.url" @click.stop>
          {{ row.Edit.text }}
        </a>
      </template>
    </kb-table-column>
  </kb-table>
  <kb-pager
    :page-nr="pager.pageNr"
    :total-pages="pager.totalPages"
    @change="changePage"
  ></kb-pager>
</div>

<script>
  (function () {
    Kooboo.loadJS([
      "/_Admin/Scripts/components/kbTable.js",
      "/_Admin/Scripts/components/kbBreadcrumb.js",
      "/_Admin/Scripts/components/kbPager.js",
    ]);
  })();
</script>
<script src="/_Admin/View/Contents/TextContentsByFolder.js"></script>
